﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PdfLibrary
{
    public class PdfAutoDictionary
    {
        public PdfDictionary BaseDictionary;
        public Dictionary<string, object> CacheDictionary = new Dictionary<string, object>();

        public PdfAutoDictionary(PdfDictionary baseDictionary)
        {
            this.BaseDictionary = baseDictionary;
        }

        public int Count { get { return BaseDictionary.Count; } }

        public object this[string key]
        {
            get
            {
                object value;
                if (!CacheDictionary.TryGetValue(key, out value))
                    CacheDictionary[key] = value = PdfObjectResolver.Resolve(BaseDictionary[key]);

                return value;
            }
        }
    }
}
